package com.huawei.appgallery.forum.message.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import com.huawei.appgallery.forum.base.card.bean.CommentReference;
import com.huawei.appgallery.forum.base.card.bean.User;
import com.huawei.appgallery.forum.cards.widget.PostTitleTextView;
import o.bqz.d;
import o.bse;
import o.btl;
import o.bvj.a;
import o.bvj.b;
import o.bvj.c;
import o.bvj.e;
import o.bvj.j;
import o.bwy;
import o.cil;
import o.cim;
import o.dof;
import o.ContentManager;

public class CommentReferenceView extends RelativeLayout implements btl {
    private String ʻ;
    private CommentReference ʼ;
    private String ʽ;
    private PostTitleTextView ˊ;
    protected Context ˋ;
    private int ˎ;
    private PostTitleTextView ˏ;
    private CommentReferenceUserView ॱ;
    private int ॱॱ;

    public void setPostTitleWidth(int i) {
        this.ॱॱ = i;
    }

    public CommentReferenceView(Context context) {
        super(context);
        ॱ(context);
    }

    public CommentReferenceView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ॱ(context);
    }

    public CommentReferenceView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ॱ(context);
    }

    public void setDomainId(String str) {
        this.ʻ = str;
        this.ॱ.setDomainId(str);
    }

    private void ॱ(Context context) {
        this.ˋ = context;
        View inflate = LayoutInflater.from(context).inflate(e.ˋ, this);
        this.ॱ = (CommentReferenceUserView) findViewById(b.ॱˊ);
        this.ˏ = (PostTitleTextView) findViewById(b.ʼ);
        this.ˊ = (PostTitleTextView) findViewById(b.ᐝ);
        this.ॱ.setUserContentClickLisenter(this);
        inflate.setOnClickListener(new 4(this));
    }

    public void setReference(CommentReference commentReference) {
        this.ʼ = commentReference;
        if (commentReference == null) {
            ॱ();
            this.ˏ.setText(bse.ˏ.ॱ(400012).ˎ());
            this.ॱ.setUser(null);
            this.ॱ.setSectionName("");
            this.ʽ = null;
            return;
        }
        User ॱ = commentReference.ॱ();
        if (ॱ != null) {
            this.ॱ.setUser(ॱ);
        }
        this.ॱ.setSectionName(commentReference.ॱॱ());
        this.ʽ = commentReference.ʽ();
        this.ˎ = commentReference.ˊ();
        ˏ(commentReference);
    }

    private void ˏ(CommentReference commentReference) {
        this.ˊ.setVisibility(8);
        if (this.ˎ == 0) {
            this.ˏ.setCompoundDrawables(null, null, null, null);
            ˊ(this.ˏ, commentReference);
        } else if (this.ˎ == 1) {
            ॱ();
            this.ˏ.setText(j.ᐝ);
            ˎ(commentReference);
        } else if (this.ˎ == 2) {
            ॱ();
            this.ˏ.setText(j.ʻ);
            ˎ(commentReference);
        } else if (this.ˎ == 3) {
            ˎ();
            ˎ(commentReference);
        } else if (this.ˎ == 4) {
            ॱ();
            ˋ();
            ˎ(commentReference);
        }
    }

    private void ˎ() {
        switch (this.ʼ.ʻ()) {
            case 1:
                this.ˏ.setText(j.ˊॱ);
                return;
            case 2:
            case 3:
                this.ˏ.setText(j.ॱॱ);
                return;
            case 5:
                this.ˏ.setText(j.ˏॱ);
                return;
            default:
                this.ˏ.setText(j.ॱ);
                return;
        }
    }

    private void ˋ() {
        switch (this.ʼ.ʻ()) {
            case 1:
                this.ˏ.setText(j.ͺ);
                return;
            case 2:
            case 3:
                this.ˏ.setText(j.ʽ);
                this.ˏ.setText(j.ʽ);
                return;
            case 5:
                this.ˏ.setText(j.ʼ);
                return;
            default:
                this.ˏ.setText(j.ˊ);
                return;
        }
    }

    private void ˎ(CommentReference commentReference) {
        User ॱ = commentReference.ॱ();
        if (ॱ != null && ॱ.ˊ() == 1) {
            this.ˊ.setVisibility(0);
            ˊ(this.ˊ, commentReference);
        }
    }

    private void ˊ(PostTitleTextView postTitleTextView, CommentReference commentReference) {
        if (dof.ʽ(commentReference.ˋ())) {
            String ˎ = commentReference.ˎ();
            if (ˎ == null) {
                postTitleTextView.setVisibility(8);
                return;
            } else if (commentReference.ॱ().ॱ() == null) {
                ॱ();
                postTitleTextView.setText(bse.ˏ.ॱ(400012).ˎ());
                return;
            } else if (!"".equals(ˎ)) {
                postTitleTextView.setVisibility(0);
                postTitleTextView.setText(ˎ.replace("[br]", "\n"));
                return;
            } else if (commentReference.ʼ()) {
                postTitleTextView.setText(d.ˋˊ);
                return;
            } else {
                return;
            }
        }
        postTitleTextView.setTextViewWidth(this.ॱॱ);
        postTitleTextView.setData(commentReference.ˋ(), commentReference.ˏ());
        postTitleTextView.setVisibility(0);
    }

    private void ॱ() {
        Drawable drawable = this.ˋ.getResources().getDrawable(c.ॱˋ);
        drawable.setBounds(0, 0, 64, 64);
        this.ˏ.setTextColor(ContentManager.getInstant().getContext().getResources().getColor(a.ˏ));
        this.ˏ.setCompoundDrawables(drawable, null, null, null);
        this.ˏ.setCompoundDrawablePadding(8);
    }

    public void ʽॱ() {
    }

    public void ॱ(boolean z) {
        cil.ˋ(this.ˋ, new cim.a().ˊ(this.ʽ).ˋ());
        if (TextUtils.isEmpty(this.ʽ)) {
            if (this.ʼ == null) {
                bwy.ˏ().ˎ(this.ˋ, this.ʽ, 400012, this.ʻ);
            } else if (this.ʼ.ॱ().ॱ() == null) {
                bwy.ˏ().ˎ(this.ˋ, this.ʽ, 400012, this.ʻ);
            }
        } else if (this.ʽ.contains("topic_detail")) {
            bwy.ˏ().ˎ(this.ˋ, this.ʽ, 0, this.ʻ);
        } else if (this.ʽ.contains("post_detail")) {
            bwy.ˏ().ˋ(this.ˋ, this.ʽ, 0, this.ʻ);
        } else if ((this.ʽ.contains("app_detail_comment") || this.ʽ.contains("app_detail_reply")) && this.ˎ != 4) {
            bwy.ˏ(this.ˋ, this.ʽ);
        }
    }

    public void setUserContentMaxWidth(int i) {
        if (this.ॱ != null) {
            this.ॱ.setUserContentMaxWidth(i);
        }
    }
}
